#ifndef							__ASOCKET_H__
#define							__ASOCKET_H__

#include						<boost/bind.hpp>
#include						<boost/asio.hpp>
#include						"handler.h"
#include						"RotatingBuffer.h"
#include						<boost/array.hpp>

class							ASocket
{
public:
	enum SocketType
	{
		UDP,
		TCP,
		BROADCASTUDP
	};

public:
	ASocket(unsigned int id) : _current_msg(0), _id(id) ,_handler(NULL) {};
	virtual ~ASocket(){}; 

public:
	virtual void				setHandler(PacketHandler * handler);
	virtual SocketType			getSocketType() const;
	virtual void				start() = 0;
	virtual	void				close() = 0;
	virtual unsigned int		getId() const;
	virtual std::string			getIp() const = 0;
	virtual std::vector<byte>	*getContent() const;

protected:
	virtual void				_startRead() = 0;
	virtual void				_handle_write(const boost::system::error_code&);
	virtual void				_getOrderSize();
	boost::array<byte, 4096>	_buffer;
	unsigned short				_current_msg;

protected:
	unsigned int				_id;
	PacketHandler				*_handler;
	SocketType					_type;
};

#endif // !__ASOCKET_H__
